function createPoBarcode(row, index) {
  if (ajaxing) { return; } showProgress(lan['Loading']);
  var filter = "PORel_Company eq '" + userinfo.Company + "'";
  filter += " and PORel_PONum eq " + row.PONum;
  filter += " and PORel_POLine eq " + row.POLine;
  filter += " and PORel_PORelNum eq " + row.PORelNum;
  api.ajax({
    url: server + 'BaqSvc/AMS_PORel/',
    method: 'get',
    returnAll: false,
    headers: {
      'Authorization': userinfo.Token,
      'Content-Type': 'application/json;charset=utf-8'
    },
    data: {
      values: {
        '$filter': filter
      }
    }
  }, function (ret, err) {
    ajaxing = 0;
    console_debug(ret, 'loadRowData');
    hideProgress();
    if (ret && ret.value[0]) {
      var param = ret.value[0];
      set_barcode(index,param);


    } else {
      
      api.toast({
        msg: lan['PartWhses_Get_Failed'],
        location: 'middle'
      });
    }

  });
}
function set_barcode(i, param) {
  var barcode = [];
  var barcode2 = [];
  // var BinNum = ""
  // var WarehouseCode = "";
  // if (param.Calculated_BinNum) {
  //   BinNum = param.Calculated_BinNum;
  // }
  // if (param.Calculated_WarehouseCode) {
  //   WarehouseCode = param.Calculated_WarehouseCode;
  // }
  // app.list[i].BinNum = BinNum;
  // app.list[i].WareHouseCode = WarehouseCode;

  if (param.Calculated_ReceivedTo == "PUR-MTL") {
    app.list[i].JobNum = param.PORel_JobNum;
    app.list[i].AssemblySeq = param.PORel_AssemblySeq;
    app.list[i].JobSeq = param.PORel_JobSeq;
    app.list[i].ReceivedTo = param.Calculated_ReceivedTo;
  }
  if (param.Calculated_ReceivedTo == "PUR-STK") {
    app.list[i].ReceivedTo = param.Calculated_ReceivedTo;
  }

  var d = new Date();
  var t = d.getTime();
  var no = 0;
  t = no ? no : t;
  var count = app.list[i].totalQty;
  app.list[i].tags = [];
  for (var k = 1; k <= count; k++) {
    var row = get_status_model();
    var row2 = get_transaction_model();
    row.Company = userinfo.Company;
    no = t + k;

    row.LabelNum = create_barcode(no + ""); //条码
    row.PartNum = app.list[i].POLinePartNum; //物料编号
    row.PartDescription = app.list[i].POLineLineDesc; //物料编号
    row.LotNum = app.list[i].LotNum; //批号
    row.WarehouseCode = app.list[i].WarehouseCode;

    // row.BinNum = BinNum;
    // row.WarehouseCode =app.list[i].WarehouseCode;


    if (k == count) {
      row.OnhandQty = app.list[i].tailQty ? app.list[i].tailQty : app.list[i].oneQty; //数量
    } else {
      row.OnhandQty = app.list[i].oneQty; //数量
    }
    row2.PartNum = row.PartNum;
    row2.Company = row.Company;
    row2.LotNum = row.LotNum;
    row2.LabelNum = row.LabelNum;
    row2.ToBinNum = app.list[i].BinNum;
    row2.ToWarehouseCode = app.list[i].WarehouseCode;
    row2.PartDescription = row.PartDescription;
    row2.TranQty = row.OnhandQty;
    row2.TranDate = app.searchdata.ArrivedDate;
    row2.TranType = "PUR-STK";
    row2.POLine = app.list[i].POLine + ""; //采购单行
    row2.PackSlip = app.searchdata.PackSlip; //送货单号
    row2.PackLine = app.list[i].PackLine;

    if (param) {
      row2.JobSeq = param.PORel_JobSeq;
      row2.AssemblySeq = param.PORel_AssemblySeq;
      row2.JobNum = param.PORel_JobNum;
    }


    row2.PONum = app.list[i].PONum; //物料编号

    barcode.push(row);
    barcode2.push(row2);

 
  }
  console_debug(barcode,barcode2);
  app.$set(app.$data.list[i], 'tags', barcode);
  app.$set(app.$data.list[i], 'tags2', barcode2);
  app.print_barcode = true;
  app.check_canclick();



}